Description
Opens a DataSource and sets some of its properties.
VBScript Code
|
Copy Code |
Function OpenAXF(p_strAXFPath)
Dim pDS
Set pDS = Application.CreateAppObject("DataSource")
pDS.Open(p_strAXFPath)
If (pDS.IsOpen) Then
Set OpenAXF = pDS
Else
Set OpenAXF = Nothing
End If
End Function
Function GetFileNameUI(p_extension, p_filter, p_title, p_flags)
GetFileNameUI = CommonDialog.ShowOpen(p_extension, p_filter, p_title, p_flags)
If (IsEmpty(GetFileNameUI)) Then
GetFileNameUI = ""
End If
End Function
Sub SetDataSourceProperties
Dim strFileName
strFileName = GetFileNameUI("axf", "ArcPad AXF Files|*.axf","Select AXF File", &H1000)
If ("" = strFileName) Then Exit Sub
Dim pDS
Set pDS = OpenAXF(strFileName)
If (pDS Is Nothing) Then
Console.Print "Open DataSource failed"
Exit Sub
End If
Dim lNumLayers
lNumLayers = pDS.Properties("LAYERCOUNT")
pDS.UserProperties("MyProp1") = "Craig"
Dim strMyProp1
strMyProp1 = pDS.UserProperties("MyProp1")
Console.Print "MyProp1 user property: " & strMyProp1
Dim lCount, strLayerName, strFolder
For lCount = 1 To lNumLayers
pDS.LayerProperties(lCount,"NAME") = "New Name" & lCount
strLayerName = pDS.LayerProperties(lCount,"NAME")
pDS.LayerProperties(lCount,"FOLDER") = "New Folder" & lCount
strFolder = pDS.LayerProperties(lCount,"FOLDER")
Console.Print "Layer " & lCount & " NAME: " & strLayerName
Console.Print "Layer " & lCount & " FOLDER: " & strFolder
Next
pDS.Close
Set pDS = Nothing
End Sub |
JScript Code
|
Copy Code |
function OpenAXF(p_strAXFPath)
{
var pDS = Application.CreateAppObject("DataSource");
pDS.Open(p_strAXFPath)
if (pDS.IsOpen)
return pDS
else
return null;
}
function GetFileNameUI(p_extension, p_filter, p_title, p_flags)
{
var resOpen = CommonDialog.ShowOpen(p_extension, p_filter, p_title, p_flags);
if (resOpen == null)
return "";
else
return resOpen;
}
function SetDataSourceProperties()
{
var strFileName = GetFileNameUI("axf", "ArcPad AXF Files|*.axf","Select AXF File", 0x1000);
if ("" == strFileName)
return;
var pDS = OpenAXF(strFileName);
if (null == pDS)
{
Console.Print("Open DataSource failed");
return;
}
var lNumLayers = pDS.Properties("LAYERCOUNT");
pDS.UserProperties("MyProp1") = "Craig";
var strMyProp1 = pDS.UserProperties("MyProp1");
Console.Print("MyProp1 user property: " + strMyProp1);
var lCount, strLayerName, strFolder ;
for (lCount = 1; lCount<=lNumLayers; lCount++)
{
pDS.LayerProperties(lCount,"NAME") = "New Name" + lCount;
strLayerName = pDS.LayerProperties(lCount,"NAME");
pDS.LayerProperties(lCount,"FOLDER") = "New Folder" + lCount;
strFolder = pDS.LayerProperties(lCount,"FOLDER");
Console.Print("Layer " + lCount + " NAME: " + strLayerName);
Console.Print("Layer " + lCount + " FOLDER: " + strFolder);
}
pDS.Close();
pDS = null;
} |